--This 2d3d browser don't use the chrome module and mouse and keyboard inputs are not working in this one.
include("shared.lua");
AddCSLuaFile("cl_init.lua");
AddCSLuaFile("shared.lua");

--################### Spawnfunction in singleplayer to drop the ads @aVoN
function ENT:SpawnFunction(p,trace)
	local e = ents.Create("advertise");
	e:SetPos(trace.HitPos + trace.HitNormal*50);
	e:DropToFloor();
	e:PhysWake();
	e:Spawn();
	e:Activate();
--	e:SetData(URL or "http://www.google.de",W or 1024,H or 768,RES or 1,ANIMATE or true,SHADE or false);
	e:SetData(URL or "http://www.youtube.com/watch?v=b6Q_koTHB54",W or 205,H or 192,RES or 5,ANIMATE or true,EnableMouse or true,ScrollBars or true,SHADE or false ); --false
	return e;
end

--################### Set Advert Data @aVoN
function ENT:SetData(...)
	self.Data = {...};
	self:__SendData();
end

--################### Get Advert Data @aVoN
function ENT:GetData()
	return unpack(self.Data);
end

--################### Send AdvertData @aVoN
function ENT:__SendData(p)
	umsg.Start("AdvertData",p);
		umsg.Entity(self.Entity);
		umsg.PoolString(self.Data[1] or "http://www.google.com");
		umsg.String(self.Data[1] or "http://www.google.com");
		umsg.Short(self.Data[2] or 0);
		umsg.Short(self.Data[3] or 0);
		umsg.Float(self.Data[4] or 1);
		umsg.Bool(self.Data[5] or false);
		umsg.Bool(self.Data[6] or false);
	umsg.End();
end

concommand.Add("__AdvertGetData",
	function(p,_,a)
		local self = Entity(a[1]);
		if(not (ValidEntity(self.Entity) and self.Entity:GetClass() == "advertise")) then return end;
		self:__SendData(p);
	end
);